home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / tools / gcc / gcc270_src.lha / gcc-2.7.0-amiga / gcc.info-9 < prev    next >
Encoding:
GNU Info File  |  1995-06-16  |  50.0 KB  |  1,194 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  7. Boston, MA 02111-1307 USA
  8.  
  9.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  10. Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided also
  18. that the sections entitled "GNU General Public License," "Funding for
  19. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  20. included exactly as in the original, and provided that the entire
  21. resulting derived work is distributed under the terms of a permission
  22. notice identical to this one.
  23.  
  24.    Permission is granted to copy and distribute translations of this
  25. manual into another language, under the above conditions for modified
  26. versions, except that the sections entitled "GNU General Public
  27. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  28. `Look And Feel'", and this permission notice, may be included in
  29. translations approved by the Free Software Foundation instead of in the
  30. original English.
  31.  
  32. 
  33. File: gcc.info,  Node: Constructors,  Next: Labeled Elements,  Prev: Initializers,  Up: C Extensions
  34.  
  35. Constructor Expressions
  36. =======================
  37.  
  38.    GNU C supports constructor expressions.  A constructor looks like a
  39. cast containing an initializer.  Its value is an object of the type
  40. specified in the cast, containing the elements specified in the
  41. initializer.
  42.  
  43.    Usually, the specified type is a structure.  Assume that `struct
  44. foo' and `structure' are declared as shown:
  45.  
  46.      struct foo {int a; char b[2];} structure;
  47.  
  48. Here is an example of constructing a `struct foo' with a constructor:
  49.  
  50.      structure = ((struct foo) {x + y, 'a', 0});
  51.  
  52. This is equivalent to writing the following:
  53.  
  54.      {
  55.        struct foo temp = {x + y, 'a', 0};
  56.        structure = temp;
  57.      }
  58.  
  59.    You can also construct an array.  If all the elements of the
  60. constructor are (made up of) simple constant expressions, suitable for
  61. use in initializers, then the constructor is an lvalue and can be
  62. coerced to a pointer to its first element, as shown here:
  63.  
  64.      char **foo = (char *[]) { "x", "y", "z" };
  65.  
  66.    Array constructors whose elements are not simple constants are not
  67. very useful, because the constructor is not an lvalue.  There are only
  68. two valid ways to use it: to subscript it, or initialize an array
  69. variable with it.  The former is probably slower than a `switch'
  70. statement, while the latter does the same thing an ordinary C
  71. initializer would do.  Here is an example of subscripting an array
  72. constructor:
  73.  
  74.      output = ((int[]) { 2, x, 28 }) [input];
  75.  
  76.    Constructor expressions for scalar types and union types are is also
  77. allowed, but then the constructor expression is equivalent to a cast.
  78.  
  79. 
  80. File: gcc.info,  Node: Labeled Elements,  Next: Cast to Union,  Prev: Constructors,  Up: C Extensions
  81.  
  82. Labeled Elements in Initializers
  83. ================================
  84.  
  85.    Standard C requires the elements of an initializer to appear in a
  86. fixed order, the same as the order of the elements in the array or
  87. structure being initialized.
  88.  
  89.    In GNU C you can give the elements in any order, specifying the array
  90. indices or structure field names they apply to.  This extension is not
  91. implemented in GNU C++.
  92.  
  93.    To specify an array index, write `[INDEX]' or `[INDEX] =' before the
  94. element value.  For example,
  95.  
  96.      int a[6] = { [4] 29, [2] = 15 };
  97.  
  98. is equivalent to
  99.  
  100.      int a[6] = { 0, 0, 15, 0, 29, 0 };
  101.  
  102. The index values must be constant expressions, even if the array being
  103. initialized is automatic.
  104.  
  105.    To initialize a range of elements to the same value, write `[FIRST
  106. ... LAST] = VALUE'.  For example,
  107.  
  108.      int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };
  109.  
  110. Note that the length of the array is the highest value specified plus
  111. one.
  112.  
  113.    In a structure initializer, specify the name of a field to initialize
  114. with `FIELDNAME:' before the element value.  For example, given the
  115. following structure,
  116.  
  117.      struct point { int x, y; };
  118.  
  119. the following initialization
  120.  
  121.      struct point p = { y: yvalue, x: xvalue };
  122.  
  123. is equivalent to
  124.  
  125.      struct point p = { xvalue, yvalue };
  126.  
  127.    Another syntax which has the same meaning is `.FIELDNAME ='., as
  128. shown here:
  129.  
  130.      struct point p = { .y = yvalue, .x = xvalue };
  131.  
  132.    You can also use an element label (with either the colon syntax or
  133. the period-equal syntax) when initializing a union, to specify which
  134. element of the union should be used.  For example,
  135.  
  136.      union foo { int i; double d; };
  137.      
  138.      union foo f = { d: 4 };
  139.  
  140. will convert 4 to a `double' to store it in the union using the second
  141. element.  By contrast, casting 4 to type `union foo' would store it
  142. into the union as the integer `i', since it is an integer.  (*Note Cast
  143. to Union::.)
  144.  
  145.    You can combine this technique of naming elements with ordinary C
  146. initialization of successive elements.  Each initializer element that
  147. does not have a label applies to the next consecutive element of the
  148. array or structure.  For example,
  149.  
  150.      int a[6] = { [1] = v1, v2, [4] = v4 };
  151.  
  152. is equivalent to
  153.  
  154.      int a[6] = { 0, v1, v2, 0, v4, 0 };
  155.  
  156.    Labeling the elements of an array initializer is especially useful
  157. when the indices are characters or belong to an `enum' type.  For
  158. example:
  159.  
  160.      int whitespace[256]
  161.        = { [' '] = 1, ['\t'] = 1, ['\h'] = 1,
  162.            ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 };
  163.  
  164. 
  165. File: gcc.info,  Node: Case Ranges,  Next: Function Attributes,  Prev: Cast to Union,  Up: C Extensions
  166.  
  167. Case Ranges
  168. ===========
  169.  
  170.    You can specify a range of consecutive values in a single `case'
  171. label, like this:
  172.  
  173.      case LOW ... HIGH:
  174.  
  175. This has the same effect as the proper number of individual `case'
  176. labels, one for each integer value from LOW to HIGH, inclusive.
  177.  
  178.    This feature is especially useful for ranges of ASCII character
  179. codes:
  180.  
  181.      case 'A' ... 'Z':
  182.  
  183.    *Be careful:* Write spaces around the `...', for otherwise it may be
  184. parsed wrong when you use it with integer values.  For example, write
  185. this:
  186.  
  187.      case 1 ... 5:
  188.  
  189. rather than this:
  190.  
  191.      case 1...5:
  192.  
  193. 
  194. File: gcc.info,  Node: Cast to Union,  Next: Case Ranges,  Prev: Labeled Elements,  Up: C Extensions
  195.  
  196. Cast to a Union Type
  197. ====================
  198.  
  199.    A cast to union type is similar to other casts, except that the type
  200. specified is a union type.  You can specify the type either with `union
  201. TAG' or with a typedef name.  A cast to union is actually a constructor
  202. though, not a cast, and hence does not yield an lvalue like normal
  203. casts.  (*Note Constructors::.)
  204.  
  205.    The types that may be cast to the union type are those of the members
  206. of the union.  Thus, given the following union and variables:
  207.  
  208.      union foo { int i; double d; };
  209.      int x;
  210.      double y;
  211.  
  212. both `x' and `y' can be cast to type `union' foo.
  213.  
  214.    Using the cast as the right-hand side of an assignment to a variable
  215. of union type is equivalent to storing in a member of the union:
  216.  
  217.      union foo u;
  218.      ...
  219.      u = (union foo) x  ==  u.i = x
  220.      u = (union foo) y  ==  u.d = y
  221.  
  222.    You can also use the union cast as a function argument:
  223.  
  224.      void hack (union foo);
  225.      ...
  226.      hack ((union foo) x);
  227.  
  228. 
  229. File: gcc.info,  Node: Function Attributes,  Next: Function Prototypes,  Prev: Case Ranges,  Up: C Extensions
  230.  
  231. Declaring Attributes of Functions
  232. =================================
  233.  
  234.    In GNU C, you declare certain things about functions called in your
  235. program which help the compiler optimize function calls and check your
  236. code more carefully.
  237.  
  238.    The keyword `__attribute__' allows you to specify special attributes
  239. when making a declaration.  This keyword is followed by an attribute
  240. specification inside double parentheses.  Eight attributes, `noreturn',
  241. `const', `format', `section', `constructor', `destructor', `unused' and
  242. `weak' are currently defined for functions.  Other attributes, including
  243. `section' are supported for variables declarations (*note Variable
  244. Attributes::.) and for types (*note Type Attributes::.).
  245.  
  246.    You may also specify attributes with `__' preceding and following
  247. each keyword.  This allows you to use them in header files without
  248. being concerned about a possible macro of the same name.  For example,
  249. you may use `__noreturn__' instead of `noreturn'.
  250.  
  251. `noreturn'
  252.      A few standard library functions, such as `abort' and `exit',
  253.      cannot return.  GNU CC knows this automatically.  Some programs
  254.      define their own functions that never return.  You can declare them
  255.      `noreturn' to tell the compiler this fact.  For example,
  256.  
  257.           void fatal () __attribute__ ((noreturn));
  258.           
  259.           void
  260.           fatal (...)
  261.           {
  262.             ... /* Print error message. */ ...
  263.             exit (1);
  264.           }
  265.  
  266.      The `noreturn' keyword tells the compiler to assume that `fatal'
  267.      cannot return.  It can then optimize without regard to what would
  268.      happen if `fatal' ever did return.  This makes slightly better
  269.      code.  More importantly, it helps avoid spurious warnings of
  270.      uninitialized variables.
  271.  
  272.      Do not assume that registers saved by the calling function are
  273.      restored before calling the `noreturn' function.
  274.  
  275.      It does not make sense for a `noreturn' function to have a return
  276.      type other than `void'.
  277.  
  278.      The attribute `noreturn' is not implemented in GNU C versions
  279.      earlier than 2.5.  An alternative way to declare that a function
  280.      does not return, which works in the current version and in some
  281.      older versions, is as follows:
  282.  
  283.           typedef void voidfn ();
  284.           
  285.           volatile voidfn fatal;
  286.  
  287. `const'
  288.      Many functions do not examine any values except their arguments,
  289.      and have no effects except the return value.  Such a function can
  290.      be subject to common subexpression elimination and loop
  291.      optimization just as an arithmetic operator would be.  These
  292.      functions should be declared with the attribute `const'.  For
  293.      example,
  294.  
  295.           int square (int) __attribute__ ((const));
  296.  
  297.      says that the hypothetical function `square' is safe to call fewer
  298.      times than the program says.
  299.  
  300.      The attribute `const' is not implemented in GNU C versions earlier
  301.      than 2.5.  An alternative way to declare that a function has no
  302.      side effects, which works in the current version and in some older
  303.      versions, is as follows:
  304.  
  305.           typedef int intfn ();
  306.           
  307.           extern const intfn square;
  308.  
  309.      This approach does not work in GNU C++ from 2.6.0 on, since the
  310.      language specifies that the `const' must be attached to the return
  311.      value.
  312.  
  313.      Note that a function that has pointer arguments and examines the
  314.      data pointed to must *not* be declared `const'.  Likewise, a
  315.      function that calls a non-`const' function usually must not be
  316.      `const'.  It does not make sense for a `const' function to return
  317.      `void'.
  318.  
  319. `format (ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)'
  320.      The `format' attribute specifies that a function takes `printf' or
  321.      `scanf' style arguments which should be type-checked against a
  322.      format string.  For example, the declaration:
  323.  
  324.           extern int
  325.           my_printf (void *my_object, const char *my_format, ...)
  326.                 __attribute__ ((format (printf, 2, 3)));
  327.  
  328.      causes the compiler to check the arguments in calls to `my_printf'
  329.      for consistency with the `printf' style format string argument
  330.      `my_format'.
  331.  
  332.      The parameter ARCHETYPE determines how the format string is
  333.      interpreted, and should be either `printf' or `scanf'.  The
  334.      parameter STRING-INDEX specifies which argument is the format
  335.      string argument (starting from 1), while FIRST-TO-CHECK is the
  336.      number of the first argument to check against the format string.
  337.      For functions where the arguments are not available to be checked
  338.      (such as `vprintf'), specify the third parameter as zero.  In this
  339.      case the compiler only checks the format string for consistency.
  340.  
  341.      In the example above, the format string (`my_format') is the second
  342.      argument of the function `my_print', and the arguments to check
  343.      start with the third argument, so the correct parameters for the
  344.      format attribute are 2 and 3.
  345.  
  346.      The `format' attribute allows you to identify your own functions
  347.      which take format strings as arguments, so that GNU CC can check
  348.      the calls to these functions for errors.  The compiler always
  349.      checks formats for the ANSI library functions `printf', `fprintf',
  350.      `sprintf', `scanf', `fscanf', `sscanf', `vprintf', `vfprintf' and
  351.      `vsprintf' whenever such warnings are requested (using
  352.      `-Wformat'), so there is no need to modify the header file
  353.      `stdio.h'.
  354.  
  355. `section ("section-name")'
  356.      Normally, the compiler places the code it generates in the `text'
  357.      section.  Sometimes, however, you need additional sections, or you
  358.      need certain particular functions to appear in special sections.
  359.      The `section' attribute specifies that a function lives in a
  360.      particular section.  For example, the declaration:
  361.  
  362.           extern void foobar (void) __attribute__ ((section ("bar")));
  363.  
  364.      puts the function `foobar' in the `bar' section.
  365.  
  366.      Some file formats do not support arbitrary sections so the
  367.      `section' attribute is not available on all platforms.  If you
  368.      need to map the entire contents of a module to a particular
  369.      section, consider using the facilities of the linker instead.
  370.  
  371. `constructor'
  372. `destructor'
  373.      The `constructor' attribute causes the function to be called
  374.      automatically before execution enters `main ()'.  Similarly, the
  375.      `destructor' attribute causes the function to be called
  376.      automatically after `main ()' has completed or `exit ()' has been
  377.      called.  Functions with these attributes are useful for
  378.      initializing data that will be used implicitly during the
  379.      execution of the program.
  380.  
  381.      These attributes are not currently implemented for Objective C.
  382.  
  383. `unused'
  384.      This attribute, attached to a function, means that the function is
  385.      meant to be possibly unused.  GNU CC will not produce a warning
  386.      for this function.
  387.  
  388. `weak'
  389.      The `weak' attribute causes the declaration to be emitted as a weak
  390.      symbol rather than a global.  This is primarily useful in defining
  391.      library functions which can be overridden in user code, though it
  392.      can also be used with non-function declarations.  Weak symbols are
  393.      supported for ELF targets, and also for a.out targets when using
  394.      the GNU assembler and linker.
  395.  
  396. `alias ("target")'
  397.      The `alias' attribute causes the declaration to be emitted as an
  398.      alias for another symbol, which must be specified.  For instance,
  399.  
  400.           void __f () { /* do something */; }
  401.           void f () __attribute__ ((weak, alias ("__f")));
  402.  
  403.      declares `f' to be a weak alias for `__f'.  In C++, the mangled
  404.      name for the target must be used.
  405.  
  406. `regparm (NUMBER)'
  407.      On the Intel 386, the `regparm' attribute causes the compiler to
  408.      pass up to NUMBER integer arguments in registers EAX, EDX, and ECX
  409.      instead of on the stack.  Functions that take a variable number of
  410.      arguments will continue to be passed all of their arguments on the
  411.      stack.
  412.  
  413. `stdcall'
  414.      On the Intel 386, the `stdcall' attribute causes the compiler to
  415.      assume that the called function will pop off the stack space used
  416.      to pass arguments, unless it takes a variable number of arguments.
  417.  
  418. `cdecl'
  419.      On the Intel 386, the `cdecl' attribute causes the compiler to
  420.      assume that the called function will pop off the stack space used
  421.      to pass arguments, unless it takes a variable number of arguments.
  422.      This is useful to override the effects of the `-mrtd' switch.
  423.  
  424.    You can specify multiple attributes in a declaration by separating
  425. them by commas within the double parentheses or by immediately
  426. following an attribute declaration with another attribute declaration.
  427.  
  428.    Some people object to the `__attribute__' feature, suggesting that
  429. ANSI C's `#pragma' should be used instead.  There are two reasons for
  430. not doing this.
  431.  
  432.   1. It is impossible to generate `#pragma' commands from a macro.
  433.  
  434.   2. There is no telling what the same `#pragma' might mean in another
  435.      compiler.
  436.  
  437.    These two reasons apply to almost any application that might be
  438. proposed for `#pragma'.  It is basically a mistake to use `#pragma' for
  439. *anything*.
  440.  
  441. 
  442. File: gcc.info,  Node: Function Prototypes,  Next: Dollar Signs,  Prev: Function Attributes,  Up: C Extensions
  443.  
  444. Prototypes and Old-Style Function Definitions
  445. =============================================
  446.  
  447.    GNU C extends ANSI C to allow a function prototype to override a
  448. later old-style non-prototype definition.  Consider the following
  449. example:
  450.  
  451.      /* Use prototypes unless the compiler is old-fashioned.  */
  452.      #if __STDC__
  453.      #define P(x) x
  454.      #else
  455.      #define P(x) ()
  456.      #endif
  457.      
  458.      /* Prototype function declaration.  */
  459.      int isroot P((uid_t));
  460.      
  461.      /* Old-style function definition.  */
  462.      int
  463.      isroot (x)   /* ??? lossage here ??? */
  464.           uid_t x;
  465.      {
  466.        return x == 0;
  467.      }
  468.  
  469.    Suppose the type `uid_t' happens to be `short'.  ANSI C does not
  470. allow this example, because subword arguments in old-style
  471. non-prototype definitions are promoted.  Therefore in this example the
  472. function definition's argument is really an `int', which does not match
  473. the prototype argument type of `short'.
  474.  
  475.    This restriction of ANSI C makes it hard to write code that is
  476. portable to traditional C compilers, because the programmer does not
  477. know whether the `uid_t' type is `short', `int', or `long'.  Therefore,
  478. in cases like these GNU C allows a prototype to override a later
  479. old-style definition.  More precisely, in GNU C, a function prototype
  480. argument type overrides the argument type specified by a later
  481. old-style definition if the former type is the same as the latter type
  482. before promotion.  Thus in GNU C the above example is equivalent to the
  483. following:
  484.  
  485.      int isroot (uid_t);
  486.      
  487.      int
  488.      isroot (uid_t x)
  489.      {
  490.        return x == 0;
  491.      }
  492.  
  493.    GNU C++ does not support old-style function definitions, so this
  494. extension is irrelevant.
  495.  
  496. 
  497. File: gcc.info,  Node: Dollar Signs,  Next: Character Escapes,  Prev: Function Prototypes,  Up: C Extensions
  498.  
  499. Dollar Signs in Identifier Names
  500. ================================
  501.  
  502.    In GNU C, you may use dollar signs in identifier names.  This is
  503. because many traditional C implementations allow such identifiers.
  504.  
  505.    On some machines, dollar signs are allowed in identifiers if you
  506. specify `-traditional'.  On a few systems they are allowed by default,
  507. even if you do not use `-traditional'.  But they are never allowed if
  508. you specify `-ansi'.
  509.  
  510.    There are certain ANSI C programs (obscure, to be sure) that would
  511. compile incorrectly if dollar signs were permitted in identifiers.  For
  512. example:
  513.  
  514.      #define foo(a) #a
  515.      #define lose(b) foo (b)
  516.      #define test$
  517.      lose (test)
  518.  
  519. 
  520. File: gcc.info,  Node: Character Escapes,  Next: Variable Attributes,  Prev: Dollar Signs,  Up: C Extensions
  521.  
  522. The Character ESC in Constants
  523. ==============================
  524.  
  525.    You can use the sequence `\e' in a string or character constant to
  526. stand for the ASCII character ESC.
  527.  
  528. 
  529. File: gcc.info,  Node: Alignment,  Next: Inline,  Prev: Type Attributes,  Up: C Extensions
  530.  
  531. Inquiring on Alignment of Types or Variables
  532. ============================================
  533.  
  534.    The keyword `__alignof__' allows you to inquire about how an object
  535. is aligned, or the minimum alignment usually required by a type.  Its
  536. syntax is just like `sizeof'.
  537.  
  538.    For example, if the target machine requires a `double' value to be
  539. aligned on an 8-byte boundary, then `__alignof__ (double)' is 8.  This
  540. is true on many RISC machines.  On more traditional machine designs,
  541. `__alignof__ (double)' is 4 or even 2.
  542.  
  543.    Some machines never actually require alignment; they allow reference
  544. to any data type even at an odd addresses.  For these machines,
  545. `__alignof__' reports the *recommended* alignment of a type.
  546.  
  547.    When the operand of `__alignof__' is an lvalue rather than a type,
  548. the value is the largest alignment that the lvalue is known to have.
  549. It may have this alignment as a result of its data type, or because it
  550. is part of a structure and inherits alignment from that structure.  For
  551. example, after this declaration:
  552.  
  553.      struct foo { int x; char y; } foo1;
  554.  
  555. the value of `__alignof__ (foo1.y)' is probably 2 or 4, the same as
  556. `__alignof__ (int)', even though the data type of `foo1.y' does not
  557. itself demand any alignment.
  558.  
  559.    A related feature which lets you specify the alignment of an object
  560. is `__attribute__ ((aligned (ALIGNMENT)))'; see the following section.
  561.  
  562. 
  563. File: gcc.info,  Node: Variable Attributes,  Next: Type Attributes,  Prev: Character Escapes,  Up: C Extensions
  564.  
  565. Specifying Attributes of Variables
  566. ==================================
  567.  
  568.    The keyword `__attribute__' allows you to specify special attributes
  569. of variables or structure fields.  This keyword is followed by an
  570. attribute specification inside double parentheses.  Eight attributes
  571. are currently defined for variables: `aligned', `mode', `nocommon',
  572. `packed', `section', `transparent_union', `unused', and `weak'.  Other
  573. attributes are available for functions (*note Function Attributes::.)
  574. and for types (*note Type Attributes::.).
  575.  
  576.    You may also specify attributes with `__' preceding and following
  577. each keyword.  This allows you to use them in header files without
  578. being concerned about a possible macro of the same name.  For example,
  579. you may use `__aligned__' instead of `aligned'.
  580.  
  581. `aligned (ALIGNMENT)'
  582.      This attribute specifies a minimum alignment for the variable or
  583.      structure field, measured in bytes.  For example, the declaration:
  584.  
  585.           int x __attribute__ ((aligned (16))) = 0;
  586.  
  587.      causes the compiler to allocate the global variable `x' on a
  588.      16-byte boundary.  On a 68040, this could be used in conjunction
  589.      with an `asm' expression to access the `move16' instruction which
  590.      requires 16-byte aligned operands.
  591.  
  592.      You can also specify the alignment of structure fields.  For
  593.      example, to create a double-word aligned `int' pair, you could
  594.      write:
  595.  
  596.           struct foo { int x[2] __attribute__ ((aligned (8))); };
  597.  
  598.      This is an alternative to creating a union with a `double' member
  599.      that forces the union to be double-word aligned.
  600.  
  601.      It is not possible to specify the alignment of functions; the
  602.      alignment of functions is determined by the machine's requirements
  603.      and cannot be changed.  You cannot specify alignment for a typedef
  604.      name because such a name is just an alias, not a distinct type.
  605.  
  606.      As in the preceding examples, you can explicitly specify the
  607.      alignment (in bytes) that you wish the compiler to use for a given
  608.      variable or structure field.  Alternatively, you can leave out the
  609.      alignment factor and just ask the compiler to align a variable or
  610.      field to the maximum useful alignment for the target machine you
  611.      are compiling for.  For example, you could write:
  612.  
  613.           short array[3] __attribute__ ((aligned));
  614.  
  615.      Whenever you leave out the alignment factor in an `aligned'
  616.      attribute specification, the compiler automatically sets the
  617.      alignment for the declared variable or field to the largest
  618.      alignment which is ever used for any data type on the target
  619.      machine you are compiling for.  Doing this can often make copy
  620.      operations more efficient, because the compiler can use whatever
  621.      instructions copy the biggest chunks of memory when performing
  622.      copies to or from the variables or fields that you have aligned
  623.      this way.
  624.  
  625.      The `aligned' attribute can only increase the alignment; but you
  626.      can decrease it by specifying `packed' as well.  See below.
  627.  
  628.      Note that the effectiveness of `aligned' attributes may be limited
  629.      by inherent limitations in your linker.  On many systems, the
  630.      linker is only able to arrange for variables to be aligned up to a
  631.      certain maximum alignment.  (For some linkers, the maximum
  632.      supported alignment may be very very small.)  If your linker is
  633.      only able to align variables up to a maximum of 8 byte alignment,
  634.      then specifying `aligned(16)' in an `__attribute__' will still
  635.      only provide you with 8 byte alignment.  See your linker
  636.      documentation for further information.
  637.  
  638. `mode (MODE)'
  639.      This attribute specifies the data type for the
  640.      declaration--whichever type corresponds to the mode MODE.  This in
  641.      effect lets you request an integer or floating point type
  642.      according to its width.
  643.  
  644.      You may also specify a mode of `byte' or `__byte__' to indicate
  645.      the mode corresponding to a one-byte integer, `word' or `__word__'
  646.      for the mode of a one-word integer, and `pointer' or `__pointer__'
  647.      for the mode used to represent pointers.
  648.  
  649. `nocommon'
  650.      This attribute specifies requests GNU CC not to place a variable
  651.      "common" but instead to allocate space for it directly.  If you
  652.      specify the `-fno-common' flag, GNU CC will do this for all
  653.      variables.
  654.  
  655.      Specifying the `nocommon' attribute for a variable provides an
  656.      initialization of zeros.  A variable may only be initialized in one
  657.      source file.
  658.  
  659. `packed'
  660.      The `packed' attribute specifies that a variable or structure field
  661.      should have the smallest possible alignment--one byte for a
  662.      variable, and one bit for a field, unless you specify a larger
  663.      value with the `aligned' attribute.
  664.  
  665.      Here is a structure in which the field `x' is packed, so that it
  666.      immediately follows `a':
  667.  
  668.           struct foo
  669.           {
  670.             char a;
  671.             int x[2] __attribute__ ((packed));
  672.           };
  673.  
  674. `section ("section-name")'
  675.      Normally, the compiler places the objects it generates in sections
  676.      like `data' and `bss'.  Sometimes, however, you need additional
  677.      sections, or you need certain particular variables to appear in
  678.      special sections, for example to map to special hardware.  The
  679.      `section' attribute specifies that a variable (or function) lives
  680.      in a particular section.  For example, this small program uses
  681.      several specific section names:
  682.  
  683.           struct duart a __attribute__ ((section ("DUART_A"))) = { 0 };
  684.           struct duart b __attribute__ ((section ("DUART_B"))) = { 0 };
  685.           char stack[10000] __attribute__ ((section ("STACK"))) = { 0 };
  686.           int init_data_copy __attribute__ ((section ("INITDATACOPY"))) = 0;
  687.           
  688.           main()
  689.           {
  690.             /* Initialize stack pointer */
  691.             init_sp (stack + sizeof (stack));
  692.           
  693.             /* Initialize initialized data */
  694.             memcpy (&init_data_copy, &data, &edata - &data);
  695.           
  696.             /* Turn on the serial ports */
  697.             init_duart (&a);
  698.             init_duart (&b);
  699.           }
  700.  
  701.      Use the `section' attribute with an *initialized* definition of a
  702.      *global* variable, as shown in the example.  GNU CC issues a
  703.      warning and otherwise ignores the `section' attribute in
  704.      uninitialized variable declarations.
  705.  
  706.      You may only use the `section' attribute with a fully initialized
  707.      global definition because of the way linkers work.  The linker
  708.      requires each object be defined once, with the exception that
  709.      uninitialized variables tentatively go in the `common' (or `bss')
  710.      section and can be multiply "defined".  You can force a variable
  711.      to be initialized with the `-fno-common' flag or the `nocommon'
  712.      attribute.
  713.  
  714.      Some file formats do not support arbitrary sections so the
  715.      `section' attribute is not available on all platforms.  If you
  716.      need to map the entire contents of a module to a particular
  717.      section, consider using the facilities of the linker instead.
  718.  
  719. `transparent_union'
  720.      This attribute, attached to a function argument variable which is a
  721.      union, means to pass the argument in the same way that the first
  722.      union member would be passed.  You can also use this attribute on a
  723.      `typedef' for a union data type; then it applies to all function
  724.      arguments with that type.
  725.  
  726. `unused'
  727.      This attribute, attached to a variable, means that the variable is
  728.      meant to be possibly unused.  GNU CC will not produce a warning
  729.      for this variable.
  730.  
  731. `weak'
  732.      The `weak' attribute is described in *Note Function Attributes::.
  733.  
  734.    To specify multiple attributes, separate them by commas within the
  735. double parentheses: for example, `__attribute__ ((aligned (16),
  736. packed))'.
  737.  
  738. 
  739. File: gcc.info,  Node: Type Attributes,  Next: Alignment,  Prev: Variable Attributes,  Up: C Extensions
  740.  
  741. Specifying Attributes of Types
  742. ==============================
  743.  
  744.    The keyword `__attribute__' allows you to specify special attributes
  745. of `struct' and `union' types when you define such types.  This keyword
  746. is followed by an attribute specification inside double parentheses.
  747. Three attributes are currently defined for types: `aligned', `packed',
  748. and `transparent_union'.  Other attributes are defined for functions
  749. (*note Function Attributes::.) and for variables (*note Variable
  750. Attributes::.).
  751.  
  752.    You may also specify any one of these attributes with `__' preceding
  753. and following its keyword.  This allows you to use these attributes in
  754. header files without being concerned about a possible macro of the same
  755. name.  For example, you may use `__aligned__' instead of `aligned'.
  756.  
  757.    You may specify the `aligned' and `transparent_union' attributes
  758. either in a `typedef' declaration or just past the closing curly brace
  759. of a complete enum, struct or union type *definition* and the `packed'
  760. attribute only past the closing brace of a definition.
  761.  
  762. `aligned (ALIGNMENT)'
  763.      This attribute specifies a minimum alignment (in bytes) for
  764.      variables of the specified type.  For example, the declarations:
  765.  
  766.           struct S { short f[3]; } __attribute__ ((aligned (8));
  767.           typedef int more_aligned_int __attribute__ ((aligned (8));
  768.  
  769.      force the compiler to insure (as fas as it can) that each variable
  770.      whose type is `struct S' or `more_aligned_int' will be allocated
  771.      and aligned *at least* on a 8-byte boundary.  On a Sparc, having
  772.      all variables of type `struct S' aligned to 8-byte boundaries
  773.      allows the compiler to use the `ldd' and `std' (doubleword load and
  774.      store) instructions when copying one variable of type `struct S' to
  775.      another, thus improving run-time efficiency.
  776.  
  777.      Note that the alignment of any given `struct' or `union' type is
  778.      required by the ANSI C standard to be at least a perfect multiple
  779.      of the lowest common multiple of the alignments of all of the
  780.      members of the `struct' or `union' in question.  This means that
  781.      you *can* effectively adjust the alignment of a `struct' or `union'
  782.      type by attaching an `aligned' attribute to any one of the members
  783.      of such a type, but the notation illustrated in the example above
  784.      is a more obvious, intuitive, and readable way to request the
  785.      compiler to adjust the alignment of an entire `struct' or `union'
  786.      type.
  787.  
  788.      As in the preceding example, you can explicitly specify the
  789.      alignment (in bytes) that you wish the compiler to use for a given
  790.      `struct' or `union' type.  Alternatively, you can leave out the
  791.      alignment factor and just ask the compiler to align a type to the
  792.      maximum useful alignment for the target machine you are compiling
  793.      for.  For example, you could write:
  794.  
  795.           struct S { short f[3]; } __attribute__ ((aligned));
  796.  
  797.      Whenever you leave out the alignment factor in an `aligned'
  798.      attribute specification, the compiler automatically sets the
  799.      alignment for the type to the largest alignment which is ever used
  800.      for any data type on the target machine you are compiling for.
  801.      Doing this can often make copy operations more efficient, because
  802.      the compiler can use whatever instructions copy the biggest chunks
  803.      of memory when performing copies to or from the variables which
  804.      have types that you have aligned this way.
  805.  
  806.      In the example above, if the size of each `short' is 2 bytes, then
  807.      the size of the entire `struct S' type is 6 bytes.  The smallest
  808.      power of two which is greater than or equal to that is 8, so the
  809.      compiler sets the alignment for the entire `struct S' type to 8
  810.      bytes.
  811.  
  812.      Note that although you can ask the compiler to select a
  813.      time-efficient alignment for a given type and then declare only
  814.      individual stand-alone objects of that type, the compiler's
  815.      ability to select a time-efficient alignment is primarily useful
  816.      only when you plan to create arrays of variables having the
  817.      relevant (efficiently aligned) type.  If you declare or use arrays
  818.      of variables of an efficiently-aligned type, then it is likely
  819.      that your program will also be doing pointer arithmetic (or
  820.      subscripting, which amounts to the same thing) on pointers to the
  821.      relevant type, and the code that the compiler generates for these
  822.      pointer arithmetic operations will often be more efficient for
  823.      efficiently-aligned types than for other types.
  824.  
  825.      The `aligned' attribute can only increase the alignment; but you
  826.      can decrease it by specifying `packed' as well.  See below.
  827.  
  828.      Note that the effectiveness of `aligned' attributes may be limited
  829.      by inherent limitations in your linker.  On many systems, the
  830.      linker is only able to arrange for variables to be aligned up to a
  831.      certain maximum alignment.  (For some linkers, the maximum
  832.      supported alignment may be very very small.)  If your linker is
  833.      only able to align variables up to a maximum of 8 byte alignment,
  834.      then specifying `aligned(16)' in an `__attribute__' will still
  835.      only provide you with 8 byte alignment.  See your linker
  836.      documentation for further information.
  837.  
  838. `packed'
  839.      This attribute, attached to an `enum', `struct', or `union' type
  840.      definition, specified that the minimum required memory be used to
  841.      represent the type.
  842.  
  843.      Specifying this attribute for `struct' and `union' types is
  844.      equivalent to specifying the `packed' attribute on each of the
  845.      structure or union members.  Specifying the `-fshort-enums' flag
  846.      on the line is equivalent to specifying the `packed' attribute on
  847.      all `enum' definitions.
  848.  
  849.      You may only specify this attribute after a closing curly brace on
  850.      an `enum' definition, not in a `typedef' declaration.
  851.  
  852. `transparent_union'
  853.      This attribute, attached to a `union' type definition, indicates
  854.      that any variable having that union type should, if passed to a
  855.      function, be passed in the same way that the first union member
  856.      would be passed.  For example:
  857.  
  858.           union foo
  859.           {
  860.             char a;
  861.             int x[2];
  862.           } __attribute__ ((transparent_union));
  863.  
  864.    To specify multiple attributes, separate them by commas within the
  865. double parentheses: for example, `__attribute__ ((aligned (16),
  866. packed))'.
  867.  
  868. 
  869. File: gcc.info,  Node: Inline,  Next: Extended Asm,  Prev: Alignment,  Up: C Extensions
  870.  
  871. An Inline Function is As Fast As a Macro
  872. ========================================
  873.  
  874.    By declaring a function `inline', you can direct GNU CC to integrate
  875. that function's code into the code for its callers.  This makes
  876. execution faster by eliminating the function-call overhead; in
  877. addition, if any of the actual argument values are constant, their known
  878. values may permit simplifications at compile time so that not all of the
  879. inline function's code needs to be included.  The effect on code size is
  880. less predictable; object code may be larger or smaller with function
  881. inlining, depending on the particular case.  Inlining of functions is an
  882. optimization and it really "works" only in optimizing compilation.  If
  883. you don't use `-O', no function is really inline.
  884.  
  885.    To declare a function inline, use the `inline' keyword in its
  886. declaration, like this:
  887.  
  888.      inline int
  889.      inc (int *a)
  890.      {
  891.        (*a)++;
  892.      }
  893.  
  894.    (If you are writing a header file to be included in ANSI C programs,
  895. write `__inline__' instead of `inline'.  *Note Alternate Keywords::.)
  896.  
  897.    You can also make all "simple enough" functions inline with the
  898. option `-finline-functions'.  Note that certain usages in a function
  899. definition can make it unsuitable for inline substitution.
  900.  
  901.    Note that in C and Objective C, unlike C++, the `inline' keyword
  902. does not affect the linkage of the function.
  903.  
  904.    GNU CC automatically inlines member functions defined within the
  905. class body of C++ programs even if they are not explicitly declared
  906. `inline'.  (You can override this with `-fno-default-inline'; *note
  907. Options Controlling C++ Dialect: C++ Dialect Options..)
  908.  
  909.    When a function is both inline and `static', if all calls to the
  910. function are integrated into the caller, and the function's address is
  911. never used, then the function's own assembler code is never referenced.
  912. In this case, GNU CC does not actually output assembler code for the
  913. function, unless you specify the option `-fkeep-inline-functions'.
  914. Some calls cannot be integrated for various reasons (in particular,
  915. calls that precede the function's definition cannot be integrated, and
  916. neither can recursive calls within the definition).  If there is a
  917. nonintegrated call, then the function is compiled to assembler code as
  918. usual.  The function must also be compiled as usual if the program
  919. refers to its address, because that can't be inlined.
  920.  
  921.    When an inline function is not `static', then the compiler must
  922. assume that there may be calls from other source files; since a global
  923. symbol can be defined only once in any program, the function must not
  924. be defined in the other source files, so the calls therein cannot be
  925. integrated.  Therefore, a non-`static' inline function is always
  926. compiled on its own in the usual fashion.
  927.  
  928.    If you specify both `inline' and `extern' in the function
  929. definition, then the definition is used only for inlining.  In no case
  930. is the function compiled on its own, not even if you refer to its
  931. address explicitly.  Such an address becomes an external reference, as
  932. if you had only declared the function, and had not defined it.
  933.  
  934.    This combination of `inline' and `extern' has almost the effect of a
  935. macro.  The way to use it is to put a function definition in a header
  936. file with these keywords, and put another copy of the definition
  937. (lacking `inline' and `extern') in a library file.  The definition in
  938. the header file will cause most calls to the function to be inlined.
  939. If any uses of the function remain, they will refer to the single copy
  940. in the library.
  941.  
  942.    GNU C does not inline any functions when not optimizing.  It is not
  943. clear whether it is better to inline or not, in this case, but we found
  944. that a correct implementation when not optimizing was difficult.  So we
  945. did the easy thing, and turned it off.
  946.  
  947. 
  948. File: gcc.info,  Node: Extended Asm,  Next: Asm Labels,  Prev: Inline,  Up: C Extensions
  949.  
  950. Assembler Instructions with C Expression Operands
  951. =================================================
  952.  
  953.    In an assembler instruction using `asm', you can now specify the
  954. operands of the instruction using C expressions.  This means no more
  955. guessing which registers or memory locations will contain the data you
  956. want to use.
  957.  
  958.    You must specify an assembler instruction template much like what
  959. appears in a machine description, plus an operand constraint string for
  960. each operand.
  961.  
  962.    For example, here is how to use the 68881's `fsinx' instruction:
  963.  
  964.      asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
  965.  
  966. Here `angle' is the C expression for the input operand while `result'
  967. is that of the output operand.  Each has `"f"' as its operand
  968. constraint, saying that a floating point register is required.  The `='
  969. in `=f' indicates that the operand is an output; all output operands'
  970. constraints must use `='.  The constraints use the same language used
  971. in the machine description (*note Constraints::.).
  972.  
  973.    Each operand is described by an operand-constraint string followed
  974. by the C expression in parentheses.  A colon separates the assembler
  975. template from the first output operand, and another separates the last
  976. output operand from the first input, if any.  Commas separate output
  977. operands and separate inputs.  The total number of operands is limited
  978. to ten or to the maximum number of operands in any instruction pattern
  979. in the machine description, whichever is greater.
  980.  
  981.    If there are no output operands, and there are input operands, then
  982. there must be two consecutive colons surrounding the place where the
  983. output operands would go.
  984.  
  985.    Output operand expressions must be lvalues; the compiler can check
  986. this.  The input operands need not be lvalues.  The compiler cannot
  987. check whether the operands have data types that are reasonable for the
  988. instruction being executed.  It does not parse the assembler
  989. instruction template and does not know what it means, or whether it is
  990. valid assembler input.  The extended `asm' feature is most often used
  991. for machine instructions that the compiler itself does not know exist.
  992. If the output expression cannot be directly addressed (for example, it
  993. is a bit field), your constraint must allow a register.  In that case,
  994. GNU CC will use the register as the output of the `asm', and then store
  995. that register into the output.
  996.  
  997.    The output operands must be write-only; GNU CC will assume that the
  998. values in these operands before the instruction are dead and need not be
  999. generated.  Extended asm does not support input-output or read-write
  1000. operands.  For this reason, the constraint character `+', which
  1001. indicates such an operand, may not be used.
  1002.  
  1003.    When the assembler instruction has a read-write operand, or an
  1004. operand in which only some of the bits are to be changed, you must
  1005. logically split its function into two separate operands, one input
  1006. operand and one write-only output operand.  The connection between them
  1007. is expressed by constraints which say they need to be in the same
  1008. location when the instruction executes.  You can use the same C
  1009. expression for both operands, or different expressions.  For example,
  1010. here we write the (fictitious) `combine' instruction with `bar' as its
  1011. read-only source operand and `foo' as its read-write destination:
  1012.  
  1013.      asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
  1014.  
  1015. The constraint `"0"' for operand 1 says that it must occupy the same
  1016. location as operand 0.  A digit in constraint is allowed only in an
  1017. input operand, and it must refer to an output operand.
  1018.  
  1019.    Only a digit in the constraint can guarantee that one operand will
  1020. be in the same place as another.  The mere fact that `foo' is the value
  1021. of both operands is not enough to guarantee that they will be in the
  1022. same place in the generated assembler code.  The following would not
  1023. work:
  1024.  
  1025.      asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
  1026.  
  1027.    Various optimizations or reloading could cause operands 0 and 1 to
  1028. be in different registers; GNU CC knows no reason not to do so.  For
  1029. example, the compiler might find a copy of the value of `foo' in one
  1030. register and use it for operand 1, but generate the output operand 0 in
  1031. a different register (copying it afterward to `foo''s own address).  Of
  1032. course, since the register for operand 1 is not even mentioned in the
  1033. assembler code, the result will not work, but GNU CC can't tell that.
  1034.  
  1035.    Some instructions clobber specific hard registers.  To describe
  1036. this, write a third colon after the input operands, followed by the
  1037. names of the clobbered hard registers (given as strings).  Here is a
  1038. realistic example for the Vax:
  1039.  
  1040.      asm volatile ("movc3 %0,%1,%2"
  1041.                    : /* no outputs */
  1042.                    : "g" (from), "g" (to), "g" (count)
  1043.                    : "r0", "r1", "r2", "r3", "r4", "r5");
  1044.  
  1045.    If you refer to a particular hardware register from the assembler
  1046. code, then you will probably have to list the register after the third
  1047. colon to tell the compiler that the register's value is modified.  In
  1048. many assemblers, the register names begin with `%'; to produce one `%'
  1049. in the assembler code, you must write `%%' in the input.
  1050.  
  1051.    If your assembler instruction can alter the condition code register,
  1052. add `cc' to the list of clobbered registers.  GNU CC on some machines
  1053. represents the condition codes as a specific hardware register; `cc'
  1054. serves to name this register.  On other machines, the condition code is
  1055. handled differently, and specifying `cc' has no effect.  But it is
  1056. valid no matter what the machine.
  1057.  
  1058.    If your assembler instruction modifies memory in an unpredictable
  1059. fashion, add `memory' to the list of clobbered registers.  This will
  1060. cause GNU CC to not keep memory values cached in registers across the
  1061. assembler instruction.
  1062.  
  1063.    You can put multiple assembler instructions together in a single
  1064. `asm' template, separated either with newlines (written as `\n') or with
  1065. semicolons if the assembler allows such semicolons.  The GNU assembler
  1066. allows semicolons and all Unix assemblers seem to do so.  The input
  1067. operands are guaranteed not to use any of the clobbered registers, and
  1068. neither will the output operands' addresses, so you can read and write
  1069. the clobbered registers as many times as you like.  Here is an example
  1070. of multiple instructions in a template; it assumes that the subroutine
  1071. `_foo' accepts arguments in registers 9 and 10:
  1072.  
  1073.      asm ("movl %0,r9;movl %1,r10;call _foo"
  1074.           : /* no outputs */
  1075.           : "g" (from), "g" (to)
  1076.           : "r9", "r10");
  1077.  
  1078.    Unless an output operand has the `&' constraint modifier, GNU CC may
  1079. allocate it in the same register as an unrelated input operand, on the
  1080. assumption that the inputs are consumed before the outputs are produced.
  1081. This assumption may be false if the assembler code actually consists of
  1082. more than one instruction.  In such a case, use `&' for each output
  1083. operand that may not overlap an input.  *Note Modifiers::.
  1084.  
  1085.    If you want to test the condition code produced by an assembler
  1086. instruction, you must include a branch and a label in the `asm'
  1087. construct, as follows:
  1088.  
  1089.      asm ("clr %0;frob %1;beq 0f;mov #1,%0;0:"
  1090.           : "g" (result)
  1091.           : "g" (input));
  1092.  
  1093. This assumes your assembler supports local labels, as the GNU assembler
  1094. and most Unix assemblers do.
  1095.  
  1096.    Speaking of labels, jumps from one `asm' to another are not
  1097. supported.  The compiler's optimizers do not know about these jumps,
  1098. and therefore they cannot take account of them when deciding how to
  1099. optimize.
  1100.  
  1101.    Usually the most convenient way to use these `asm' instructions is to
  1102. encapsulate them in macros that look like functions.  For example,
  1103.  
  1104.      #define sin(x)       \
  1105.      ({ double __value, __arg = (x);   \
  1106.         asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
  1107.         __value; })
  1108.  
  1109. Here the variable `__arg' is used to make sure that the instruction
  1110. operates on a proper `double' value, and to accept only those arguments
  1111. `x' which can convert automatically to a `double'.
  1112.  
  1113.    Another way to make sure the instruction operates on the correct
  1114. data type is to use a cast in the `asm'.  This is different from using a
  1115. variable `__arg' in that it converts more different types.  For
  1116. example, if the desired type were `int', casting the argument to `int'
  1117. would accept a pointer with no complaint, while assigning the argument
  1118. to an `int' variable named `__arg' would warn about using a pointer
  1119. unless the caller explicitly casts it.
  1120.  
  1121.    If an `asm' has output operands, GNU CC assumes for optimization
  1122. purposes that the instruction has no side effects except to change the
  1123. output operands.  This does not mean that instructions with a side
  1124. effect cannot be used, but you must be careful, because the compiler
  1125. may eliminate them if the output operands aren't used, or move them out
  1126. of loops, or replace two with one if they constitute a common
  1127. subexpression.  Also, if your instruction does have a side effect on a
  1128. variable that otherwise appears not to change, the old value of the
  1129. variable may be reused later if it happens to be found in a register.
  1130.  
  1131.    You can prevent an `asm' instruction from being deleted, moved
  1132. significantly, or combined, by writing the keyword `volatile' after the
  1133. `asm'.  For example:
  1134.  
  1135.      #define set_priority(x)  \
  1136.      asm volatile ("set_priority %0": /* no outputs */ : "g" (x))
  1137.  
  1138. An instruction without output operands will not be deleted or moved
  1139. significantly, regardless, unless it is unreachable.
  1140.  
  1141.    Note that even a volatile `asm' instruction can be moved in ways
  1142. that appear insignificant to the compiler, such as across jump
  1143. instructions.  You can't expect a sequence of volatile `asm'
  1144. instructions to remain perfectly consecutive.  If you want consecutive
  1145. output, use a single `asm'.
  1146.  
  1147.    It is a natural idea to look for a way to give access to the
  1148. condition code left by the assembler instruction.  However, when we
  1149. attempted to implement this, we found no way to make it work reliably.
  1150. The problem is that output operands might need reloading, which would
  1151. result in additional following "store" instructions.  On most machines,
  1152. these instructions would alter the condition code before there was time
  1153. to test it.  This problem doesn't arise for ordinary "test" and
  1154. "compare" instructions because they don't have any output operands.
  1155.  
  1156.    If you are writing a header file that should be includable in ANSI C
  1157. programs, write `__asm__' instead of `asm'.  *Note Alternate Keywords::.
  1158.  
  1159. 
  1160. File: gcc.info,  Node: Asm Labels,  Next: Explicit Reg Vars,  Prev: Extended Asm,  Up: C Extensions
  1161.  
  1162. Controlling Names Used in Assembler Code
  1163. ========================================
  1164.  
  1165.    You can specify the name to be used in the assembler code for a C
  1166. function or variable by writing the `asm' (or `__asm__') keyword after
  1167. the declarator as follows:
  1168.  
  1169.      int foo asm ("myfoo") = 2;
  1170.  
  1171. This specifies that the name to be used for the variable `foo' in the
  1172. assembler code should be `myfoo' rather than the usual `_foo'.
  1173.  
  1174.    On systems where an underscore is normally prepended to the name of
  1175. a C function or variable, this feature allows you to define names for
  1176. the linker that do not start with an underscore.
  1177.  
  1178.    You cannot use `asm' in this way in a function *definition*; but you
  1179. can get the same effect by writing a declaration for the function
  1180. before its definition and putting `asm' there, like this:
  1181.  
  1182.      extern func () asm ("FUNC");
  1183.      
  1184.      func (x, y)
  1185.           int x, y;
  1186.      ...
  1187.  
  1188.    It is up to you to make sure that the assembler names you choose do
  1189. not conflict with any other assembler symbols.  Also, you must not use a
  1190. register name; that would produce completely invalid assembler code.
  1191. GNU CC does not as yet have the ability to store static variables in
  1192. registers.  Perhaps that will be added.
  1193.  
  1194.